#!/bin/bash

cd ../build/

start_time=$(date +%s) # %s可以计算的是1970年以来的秒数

# 合成数据集，authentic dataset
#for dist in linear_64M linear_64Mseg1 linear_64Mseg10 norm_64M; do
#    ./read_cold -f ../db/sosd/${dist}.txt -k 16 -v 64 -d ../ssd/db_ddist_${dist}_16 -m 7 -w > ../evaluation/${dist}_16_put.txt
#    ./read_cold -f ../db/sosd/${dist}.txt -k 16 -v 64 -d ../ssd/db_ddist_${dist}_16_random -m 7 -w -l 3 > ../evaluation/${dist}_16_random_put.txt
#done

# idf_all
#for dist in idf_all; do
#    ./read_cold -f ../db/dataset/${dist}.txt -k 16 -v 64 -d ../ssd/db_ddist_${dist}_16 -m 7 -w > ../evaluation/${dist}_16_put.txt
##    ./read_cold -f ../db/dataset/${dist}.txt -k 16 -v 64 -d ../ssd/db_ddist_${dist}_16_random -m 7 -w -l 3 > ../evaluation/${dist}_16_random_put.txt
#done


# idf_single_valid
#for dist in idf_575_valid idf_95_valid idf_175_valid idf_351_valid; do
#    ./read_cold -f ../db/ali_single_valid_index/${dist}.txt -k 16 -v 64 -d ../ssd/db_ddist_${dist}_16 -m 7 -w > ../evaluation/${dist}_16_put.txt
#    ./read_cold -f ../db/ali_single_valid_index/${dist}.txt -k 16 -v 64 -d ../ssd/db_ddist_${dist}_16_random -m 7 -w -l 3 > ../evaluation/${dist}_16_random_put.txt
#done


# AR
#./read_cold -f ../db/dataset/amazon_reviews.txt -k 16 -v 64 -d ../ssd/db_ar_16 -m 7 -w > ../evaluation/ar_16_put.txt
#./read_cold -f ../db/dataset/amazon_reviews.txt -k 16 -v 64 -d ../ssd/db_ar_16_random -m 7 -w -l 3 > ../evaluation/ar_16_random_put.txt

# OSM
#./read_cold -f ../db/dataset/osm_ny.txt -k 16 -v 64 -d ../ssd/db_osm_16 -m 7 -w > ../evaluation/osm_16_put.txt
#./read_cold -f ../db/dataset/osm_ny.txt -k 16 -v 64 -d ../ssd/db_osm_16_random -m 7 -w -l 3 > ../evaluation/osm_16_random_put.txt


# YCSB Default tarces
#./read_cold -f ../db/ycsb/ori_0.3M_put.txt -k 19 -v 64 -d ../ssd/ycsb_default_0.3M -m 7 -w > ../evaluation/ycsb_default_0.3M_put.txt
#./read_cold -f ../db/ycsb/ori_0.3M_put.txt -k 19 -v 64 -d ../ssd/ycsb_default_0.3M_random -m 7 -w -l 3 > ../evaluation/ycsb_default_0.3M_random_put.txt

# ali
#./read_cold -f ../db/dataset/idf_all.txt -k 16 -v 64 -d ../ssd/db_idf_all_16 -m 7 -w > ../evaluation/idf_all_16_put.txt
#./read_cold -f ../db/dataset/idf_all.txt -k 16 -v 64 -d ../ssd/db_idf_all_16_random -m 7 -w -l 3 > ../evaluation/idf_all_16_random_put.txt

# ali_idf_351_valid
#./read_cold -f ../db/ali_single_valid_index/idf_351_valid.txt -k 19 -v 64 -d ../ssd/db_idf_351_valid_19_random -m 7 -w -l 3 > ../evaluation/db_idf_351_valid_19_random_put.txt

#./read_cold -f ../db/ali_single_valid_index/idf_175_valid.txt -k 19 -v 64 -d ../ssd/db_idf_175_valid_19_random -m 7 -w -l 3 > ../evaluation/db_idf_175_valid_19_random_put.txt

#./read_cold -f ../index_parsed_txt/idf_758.txt -k 16 -v 64 -d ../ssd/db_idf_758_16_random -m 7 -w -l 3 > ../evaluation/db_idf_758_16_random_put.txt

# 最新的trace数据
db_path="$1"
# delete ../ , then delete .txt .
data_name_=${db_path#*../}
data_name=${data_name_%.txt*}

./read_cold_trace -f "$db_path" -k 16 -v 64 -d ../ssd/db_"$data_name" -m 7 -w -l 3 > ../evaluation/"$data_name"_put.txt
#-f ../111969901601639.txt -k 16 -v 64 -d ../ssd/db_111969901601639 -m 7 -w -l 3 > ../evaluation/111969901601639_put.txt


#sudo ./read_cold_trace -f ../db/dataset/amazon_reviews.txt -k 16 -v 64 -d ../ssd/amazon_reviews -m 7 -w -l 3 > ../evaluation/amazon_reviews_put.txt

end_time=$(date +%s)
cost_time=$((end_time-start_time))
echo "$0" "运行时间：$((cost_time/60))min $((cost_time%60))s"